
const doSync = (sth, time) => {
    return (new Promise(resolve => {
        setTimeout(() => {
            console.log(sth + '用了' + time + '毫秒')
            resolve()
        }, time)
    }))
}
const doAsync = (sth, time, cb) =>{
    setTimeout(() => {
        console.log(sth + '用了' + time + '毫秒')
        cb && cb()
    }, time)
}

const deElse = (sth) => {
    console.log(sth)
}

const Scott = {doSync, doAsync}
const Meizi = {doSync, doAsync, deElse}


;(async()=> {
    console.log('case 1: 妹子来到门口')
    await Scott.doSync('Scott 刷牙', 1000)
    console.log('啥也没干，一直在等')
    await Meizi.doSync('妹子洗澡', 2000)
    console.log('妹子去忙别的去了')

    console.log('case 3: 妹子来到门口按下通知开关--async')
    await Scott.doAsync('Scott 刷牙', 1000, () => {
        console.log('卫生间通知妹子来洗澡')
        Meizi.doAsync('妹子洗澡', 2000)
    })
    console.log('妹子去忙别的去了')
})()